# Replication File for
# "Coalition Inclusion Probabilities: A Party-Strategic
# Measure for Predicting Policy and Politics
# Authors: Mark A. Kayser, Matthias Orlowski
# and Jochen Rehmert
# Code to replicate Figure 1

# set your directory to the folder with
# "data_Figure1.RDS" data file 
setwd('...')


# load necessary packages
library(openxlsx);library(ggplot2)

# read data
dat <- readRDS("data_Figure1.RDS")

# --- Figure 1 --- #
p <- ggplot(dat[dat$polls <= 0.6,])
p = p + geom_line(aes(x = polls, y = cip, colour = as.factor(party)), size = 1.1)
p = p + facet_wrap(. ~ party, nrow = 1)
p = p + xlab("Seatshare Party A") + ylab("Coalition Inclusion Probability")
p = p + theme(axis.text = element_text(size = 15, face = "bold", color = "black"),
              axis.title = element_text(size = 16, face = "bold"),
              strip.background =element_rect(fill="white", colour = "black"),
              strip.text = element_text(colour = 'black', size = 15, face = "bold"),
              panel.grid.major.y = element_line(colour = "grey"),
              panel.grid.minor = element_line(colour = "white"),
              panel.background = element_rect(fill = "white"),
              panel.spacing = unit(2, "lines"),
              legend.position = "none")
 
p 

